#ifndef BDATA_H
#define BDATA_H

/*
 *  bdata.h
 *
 * Prototypes for the btree data struct
 */

/* Defines the data type that will be used to specify the
 * key; used in comparisons. */
typedef char * Key;

/* Simplifies syntax for selecting one of the frequency fields
 * during the insertion process for the btree. */
enum _freq {
    FREQ_IN = 0,
    FREQ_OUT = 1
} FREQ;

/* Defines the data struct stored in btree nodes. The freq_in field
 * stores the number of times the key appeared in the first file, while
 * the freq_out does the same for the second file.*/
typedef struct _btdata_elmt {
    Key key;
    int freq_in;
    int freq_out;
} * BTData;

/* Initialize a BTData struct with a key */
BTData btdata_init (Key);

/* Free the BTData struct while returning the difference between the
 * freq_in and freq_out values. This behaviour is unique to this
 * assignment, as we can free memory AND data mine at the same time. */
int btdata_free (BTData);

/* Compare two keys; the first argument is defined as the static key,
 * while the second key is defined as the dynamic key (this key will
 * generally be the key of a node in the btree that changes during
 * traversal. Returns -1 if static < dynamic, 0 if static = dynamic or
 * 1 if static > dynamic.*/
int btdata_compare_keys (Key, Key);

/* Increment a specific frequency counter depending on the second argument */
void btdata_inc_freq (BTData, FREQ);

#endif /* BDATA_H */
